package site.xuxingcan.cheatgps;

import android.content.Context;
import android.support.annotation.NonNull;

public class CheatGPSManager {

    private static final String TAG = "CheatGPSManager";

    private static CheatGPSManager INSTANCE = new CheatGPSManager();
    private Context mContext;
    private LocationThread mLocationThread;
    private boolean mIsStarted = false;

    private LocationPoint mCurrentLocPoint;
    private CheatGPSManager() {
    }


    public void init(Context context) {
        mContext = context;
    }

    public static CheatGPSManager getInstance() {
        return INSTANCE;
    }

    public void start(@NonNull LocationPoint locPoint) {
        mCurrentLocPoint = locPoint;
        if (mLocationThread == null || !mLocationThread.isAlive()) {
            mLocationThread = new LocationThread(mContext.getApplicationContext(), this);
            mLocationThread.startThread();
        }
        mIsStarted = true;
    }

    public void stop() {
        if (mLocationThread != null) {
            mLocationThread.stopThread();
            mLocationThread = null;
        }
        mIsStarted = false;
    }

    public boolean isStarted() {
        return mIsStarted;
    }

    public LocationPoint getCurrentLocPoint() {
        return mCurrentLocPoint;
    }

    public void goToLocation(@NonNull LocationPoint location) {
        mCurrentLocPoint = location;
    }
}
